const Sequelize = require("sequelize");
const db = require("../database/db");
const dayjs = require('dayjs');
const {formatDate} = require("../utils/date");

module.exports = db.sequelize.define('airship', {
  id: {
    type: Sequelize.INTEGER,
    primaryKey: true, // 设为主键
    autoIncrement: true // 启用自增功能
  },
  rank:{
    type: Sequelize.INTEGER,
  },
  gernerate_date:{
    type: Sequelize.DATE,
    get() {
      return formatDate(this.getDataValue('gernerate_date'))
    }
  },
  //大小差值
  size_diff:{
    type: Sequelize.INTEGER,
  },
  //大小当日最大差值
  size_max_diff:{
    type: Sequelize.INTEGER,
  },
  //大小当日最大差值时间
  size_max_diff_time:{
    type: Sequelize.DATE,
    get() {
      return formatDate(this.getDataValue('size_max_diff_time'))
    }
  },
  // 单双差值
  single_double_diff:{
    type: Sequelize.INTEGER,
  },
  
  //单双当日最大差值
  single_double_max_diff:{
    type: Sequelize.INTEGER,
  },
  //单双当日最大差值时间
  single_double_max_diff_time:{
    type: Sequelize.DATE,
    get() {
      return formatDate(this.getDataValue('single_double_max_diff_time'))
    }
  },
  //大值
  big_value:{
    type: Sequelize.INTEGER,
  },
  //小值
  small_value:{
    type: Sequelize.INTEGER,
  },
  //单值
  single_value:{
    type: Sequelize.INTEGER,
  },
  //双值
  double_value:{
    type: Sequelize.INTEGER,
  },

  
  createTime: {
    type: Sequelize.DATE,
    // 设置默认值为当前时间
    defaultValue: Sequelize.NOW,
    get() {
      return formatDate(this.getDataValue('createTime'))
    }
  },

}, {
  timestamps: false, // 不自动加上 createdAt 和 updatedAt
  freezeTableName: true, // 强制表名称等于模型名称，不自动将模型名复数并将其用作表名
})